# Maintainer: Balló György <ballogyor+arch at gmail dot com>

pkgname=gnac
pkgver=0.2.4.1
pkgrel=12
pkgdesc='Audio converter for GNOME'
arch=('loong64' 'x86_64')
url='http://gnac.sourceforge.net/'
license=('GPL3')
depends=('libnotify' 'gst-plugins-base' 'gtk3')
makedepends=('intltool' 'gnome-common')
optdepends=('gst-plugins-good: Extra media codecs'
            'gst-plugins-bad: Extra media codecs'            
            'gst-plugins-ugly: Extra media codecs'
            'gst-libav: Extra media codecs')
source=("https://downloads.sourceforge.net/$pkgname/$pkgname-$pkgver.tar.bz2"
        'gnac.appdata.xml'
        'fix-build.patch'
        'gcc10.patch'
        'gstreamer-1.0.patch'
        '0001-Use-GLib-debug-functions.patch'
        '0001-Add-support-for-OPUS-format.patch'
        'yelp-tools.patch')
sha256sums=('8f9c4731bbc40fde57c311a2a7fabe4e3200198abfe7415c659b98a2d54869da'
            '936ff9d1830c2649a34cbd1f208fb572de6dd2f89aeefa20e750227287125774'
            'a7a8cc9d3cc9408776e64be50beb7c48cc1a3d9499cb98e2dac5f45a151475ac'
            'd94ced106d64b9ead233cb55f32a2ce6b8d0259ef0ec834a38c892ae16627ca3'
            '5db70167ffb8111b0ac6e50a7998281e21eee713e663ce20024ca45f9cbb29f6'
            '0682b6182a4e20ec93928d02b46e181233f931828994a8b177a2f8dcd7eda5e1'
            '42a73a431601d7828b043d0563f85b22d705117dbf1c8bd3f4b1cd9bf58fa629'
            '19bbf1437e3e90da9d2971bdcbd21a95e217ba559d0d8f34554ee8cdfa1f787c')

prepare() {
  cd $pkgname-$pkgver

  # Fix build
  patch -Np1 -i ../fix-build.patch
  patch -Np1 -i ../gcc10.patch

  # Port to GStreamer 1.0
  patch -Np1 -i ../gstreamer-1.0.patch

  # Use GLib debug functions
  patch -Np1 -i ../0001-Use-GLib-debug-functions.patch

  # Add support for OPUS format
  patch -Np1 -i ../0001-Add-support-for-OPUS-format.patch

  # Don't use deprecated gnome-doc-utils
  patch -Np1 -i ../yelp-tools.patch
  
  # Don't install icon into pixmaps
  sed -i '/pixmaps/d' data/icons/Makefile.am

  autoreconf -fi
  intltoolize --force
}

build() {
  cd $pkgname-$pkgver
  ./configure --prefix=/usr --disable-schemas-compile
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
  install -Dm644 ../gnac.appdata.xml "$pkgdir/usr/share/metainfo/gnac.appdata.xml"
}
